//
//  TSFindTopicCellViewModel.m
//  TaShuo
//
//  Created by N-X on 2018/3/19.
//  Copyright © 2018年 MRNAN. All rights reserved.
//

#import "TSFindTopicCellViewModel.h"
#import "TSFindTopicCollectionCell.h"
#import "TSFindTopicItemViewModel.h"

@interface TSFindTopicCellViewModel()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>

@end
@implementation TSFindTopicCellViewModel
- (void)bindView:(UIView *)view
{
    UICollectionView * collectionView = (UICollectionView *)view;
    collectionView.delegate = self;
    collectionView.dataSource = self;
    [collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([TSFindTopicCollectionCell class]) bundle:nil] forCellWithReuseIdentifier:kFindTopicCollectionCellID];
}

#pragma mark - UICollectionViewDataSource,UICollectionViewDelegate

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.topicItems.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    TSFindTopicCollectionCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:kFindTopicCollectionCellID forIndexPath:indexPath];
    TSFindTopicItemViewModel * itemVM = self.topicItems[indexPath.item];
    [itemVM bindView:cell];
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return collectionView.frame.size;
}
@end
